<template>
	<view>
		
		<!-- 新闻分段器 -->
		<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem"  styleType="text"
			activeColor="#1895f3" style="width: 100%;margin: 0 auto; height: 25px;background-color: #FFF;">
		</uni-segmented-control>
		<view class="content">
			<!-- 企业动态 -->
			<view v-show="current === 0" style="width: 90%;height:100%; margin: 0 auto;margin-top: 15rpx;">
				<!-- 搜索框 -->
				<view style="height: 100rpx;">
					<u-search :clearabled="true" bgColor="#fff" :showAction="false" placeholder="请根据新闻标题搜索" v-model="theme" style="height: 110rpx;"
					@search="findXinWenName()" ></u-search>
				</view>
				<view v-for="i in type0">
					<view style="width: 100%;height: 105px;border-radius: 15px;background-color: #FFF;margin-top: 30rpx;" @click="findxwID(i.jourid)">
						<view style="width: 210rpx;height: 210rpx;float: left;margin-left: 35rpx;">
							<image :src="i.jimage" 
							style="width: 180rpx;height: 180rpx;border-radius: 15px;margin-top: 9px;"></image>
						</view>
						<view style="width: 420rpx;height: 180rpx;float: left;margin-top: 9px;">
							<view >
								<u--text class="uni-body" :lines="2" :text="i.theme"></u--text>
								<u--text class="uni-body" :lines="2" :text="i.content"></u--text>
							</view>
							<view style="overflow: hidden; margin-top: 10rpx;">
								<view style="float: left;width: 20px;margin-top: 9rpx;"><u-icon name="eye" ></u-icon></view>
								<u--text type="info"  style="font-size: 14px; float: left; width: 70px;"  :text="i.num"></u--text>
							</view>
						</view>
					</view>
				
				</view>
			</view>
			<!-- 产品新闻  -->
			<view v-show="current === 1"  style="width: 90%;height:100%; margin: 0 auto;margin-top: 15rpx;">
				<!-- 搜索框 -->
				<view style="height: 100rpx;">
					<u-search :clearabled="true" bgColor="#fff" :showAction="false" placeholder="请根据新闻标题搜索" v-model="theme" style="height: 110rpx;"
					@search="findXinWenName()" ></u-search>
				</view>
				<view  v-for="i1 in type1">
					<view style="width: 100%;height: 105px;border-radius: 15px;background-color: #FFF;margin-top: 30rpx;"@click="findxwID(i1.jourid)">
						<view style="width: 210rpx;height: 210rpx;float: left;margin-left: 35rpx;">
							<image :src="i1.jimage" 
							style="width: 180rpx;height: 180rpx;border-radius: 15px;margin-top: 9px;"></image>
						</view>
						<view style="width: 420rpx;height: 180rpx;float: left;margin-top: 9px;">
							<view style="">
								<u--text class="uni-body" :lines="2" :text="i1.theme"></u--text>
								<u--text class="uni-body" :lines="2" :text="i1.content"></u--text>
							</view>
							<view style="overflow: hidden; margin-top: 10rpx;">
								<view style="float: left;width: 20px;margin-top: 9rpx;"><u-icon name="eye" ></u-icon></view>
								<u--text type="info"  style="font-size: 14px; float: left; width: 70px;"  :text="i1.num"></u--text>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 行业信息  -->
			<view v-show="current === 2"  style="width: 90%;height:100%; margin: 0 auto;margin-top: 15rpx;">
				<!-- 搜索框 -->
				<view style="height: 100rpx;">
					<u-search :clearabled="true" bgColor="#fff" :showAction="false" placeholder="请根据新闻标题搜索" v-model="theme" style="height: 110rpx;"
					@search="findXinWenName()" ></u-search>
				</view>
				<view v-for="i2 in type2"> 
					<view style="width: 100%;height: 105px;border-radius: 15px;background-color: #FFF;margin-top: 30rpx;"@click="findxwID(i2.jourid)">
						<view style="width: 210rpx;height: 210rpx;float: left;margin-left: 35rpx;">
							<image :src="i2.jimage" 
							style="width: 180rpx;height: 180rpx;border-radius: 15px;margin-top: 9px;"></image>
						</view>
						<view style="width: 420rpx;height: 180rpx;float: left;margin-top: 9px;">
							<view style="">
								<u--text class="uni-body" :lines="2" :text="i2.theme"></u--text>
								<u--text class="uni-body" :lines="2" :text="i2.content"></u--text>
							</view>
							<view style="overflow: hidden; margin-top: 10rpx;">
								<view style="float: left;width: 20px;margin-top: 9rpx;"><u-icon name="eye" ></u-icon></view>
								<u--text type="info"  style="font-size: 14px; float: left; width: 70px;"  :text="i2.num"></u--text>
							</view>
						</view>
					</view>
					
						
					</view>
				</view>
			</view>
		
		</view>
	</view>
</template>

<script>
	import request from '../../../../utils/request.js';
	export default {
		data() {
			return {
				theme:"",
				current: 0,
				items: ['企业动态', '产品新闻', '行业信息'],
				xwList:[],
				type0:[],
				type1:[],
				type2:[]
			}
			
		},
		onLoad() {
			this.findxw2();
			this.findxw1();
			this.findxw0();
			this.hfindAllXinwen();
		},
		onShow() {
			this.findxw2();
			this.findxw1();
			this.findxw0();
		},
		methods: {
			// 根据xw标题搜索
			findXinWenName(theme){
				request({
					url:'fragmentary/findXinWenName?theme='+this.theme,
					method:'post',
					success: (res) => {
						this.type0=res.data.data.data
						// console.log(this.gaoList+/"-----------------------所有公告")
					},
					fail: (res) => {
						console.log("11111111111111111111111111")
					},
				})
			},
			// 详细信息
			findxwID(jourid){
				uni.navigateTo({
					url:"./XinwenInfo?jourid="+jourid
				})
			},
			// type2
			findxw2(){
				request({
					url:'fragmentary/findxw2',
					method:'post',
					success: (res) => {
						this.type2=res.data.data.data
					},
					fail: (res) => {
						console.log("异常")
					},
				})
			},
			// type1
			findxw1(){
				request({
					url:'fragmentary/findxw1',
					method:'post',
					success: (res) => {
						this.type1=res.data.data.data
					},
					fail: (res) => {
						console.log("异常")
					},
				})
			},
			// type0
			findxw0(){
				request({
					url:'fragmentary/findxw0',
					method:'post',
					success: (res) => {
						this.type0=res.data.data.data
					},
					fail: (res) => {
						console.log("异常")
					},
				})
			},
			hfindAllXinwen(){
				request({
					url:'fragmentary/hfindAllXinwen',
					method:'post',
					success: (res) => {
						this.xwList=res.data.data.data
					},
					fail: (res) => {
						console.log("异常")
					},
				})
			},
			search(res) {
				uni.showToast({
					title: '搜索：' + res.value,
					icon: 'none'
				})
			},
			onClickItem(e) {
				if (this.current !== e.currentIndex) {
					this.current = e.currentIndex
				}
			
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	.search-result {
		padding-top: 10px;
		padding-bottom: 20px;
		text-align: center;
	}

	.search-result-text {
		text-align: center;
		font-size: 14px;
		color: #666;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		padding: 0px;
	}

	.uni-mt-10 {
		margin-top: 10px;
	}
</style>
